﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogicComponents
{
    public class GateAnd
    {
        private Wire _inputA,_inputB, _exit;

        private void operate()
        {
            _exit.setValue(_inputA.getValue() && _inputB.getValue() );
        }

        public GateAnd()
        {
            _inputA = new Wire();
            _inputB = new Wire();
            _exit = new Wire();
            operate();
        }
        public GateAnd(Wire inputA ,Wire inputB)
        {
            _inputA = new Wire(inputA );
            _inputA.ValueChanged += operate;
            _inputB = new Wire(inputB );
            _inputB.ValueChanged += operate;
            _exit = new Wire();
            operate();
        }

        public void setInputAWire(Wire inputA)
        {
            _inputA.setOriginWire(inputA);
            _inputA.ValueChanged += operate;
            operate();
        }
        public void setInputBWire(Wire inputB)
        {
            _inputB.setOriginWire(inputB);
            _inputB.ValueChanged += operate;
            operate();
        }
        public Wire getInputA()
        {
            return _inputA;
        }
        public Wire getInputB()
        {
            return _inputB;
        }
        public Wire getExit ()
        {
            return _exit;
        }
        public bool getExitValue()
        {
            return _exit.getValue();
        }
        public void setInputAValue(bool value)
        {
            _inputA.setValue(value);
            operate();
        }
        public void setInputBValue(bool value)
        {
            _inputB.setValue(value);
            operate();
        }
        public void setInputValues (bool valueA , bool valueB)
        {
            _inputA.setValue(valueA);
            _inputB.setValue(valueB);
        }






    }
}
